package com.gui.hosp.controller;

import com.gui.common.result.Result;
import com.gui.hosp.service.ScheduleService;
import com.gui.model.hosp.Schedule;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author GodLamp
 * @date 2022/10/22 20:51
 */
@RestController
@RequestMapping(path = "/admin/hosp/schedule")
public class ScheduleController {
    @Resource
    private ScheduleService scheduleService;

    @ApiOperation(value = "根据医院编号、科室编号查询排班规则信息")
    @GetMapping(path = "getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRule(@PathVariable(name = "page") Integer page,
                                  @PathVariable(name = "limit") Integer limit,
                                  @PathVariable(name = "hoscode") String hoscode,
                                  @PathVariable(name = "depcode") String depcode){
        Map<String, Object> map = scheduleService.getRuleSchedule(page, limit, hoscode, depcode);

        return Result.ok(map);
    }

    @ApiOperation(value = "根据医院编号、科室编号、工作日期查询排班详细信息")
    @GetMapping(path = "getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public Result getScheduleDetail(@PathVariable(name = "hoscode") String hoscode,
                                    @PathVariable(name = "depcode") String depcode,
                                    @PathVariable(name = "workDate") String workDate){
        List<Schedule> list = scheduleService.getDetailSchedule(hoscode, depcode, workDate);

        return Result.ok(list);
    }
}
